<template>
  <!-- 搜索框 -->
  <van-search v-model="searchValue" show-action placeholder="请输入搜索关键词" @search="onSearch" shape="round"
      :background="bgcColor" @focus="toSearch">
      <template #action>
        <van-icon name="more-o" size="24" :color="iconColor" />
      </template>
    </van-search>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import router from '@/router';

//接受传来的背景色
const props = defineProps(['bgcColor','iconColor'])

const searchValue = ref('')

const toSearch = ()=>{
  router.push({
    path:'/search'
  })
}
//点击搜索（enter）
const onSearch = () => {
  console.log(1)
}
</script>

<style lang="less" scoped>
  van-search {
    height: 40px;
    font-size: 16px;
    line-height: 40px;
  }
</style>
